<?php
namespace App\Services\Fund;
use App\Services\Fund\Withdraw\WithdrawLogic;
use App\Services\User\Token;
use App\Services\User\App;
use Request;
/**
 * 数字币冻结日志
 * Class Withdraw
 * @package App\Services\Fund
 */
class Withdraw
{



    /*
    $app_key = config('tpproject.yayi_admin_app_key');
        $token = (new Token())->hGetAll($data['token']);
        if($token['res']['status'] != SUCCESS_STATUS){
            return $token;
        }
        $find = (new App())->find(['app_key'=>$app_key]);
        if($find['res']['status'] != SUCCESS_STATUS){
            return $find ;
        }*/
     /*我的 - 申请提现*/
   /* public function applyDrawwith($data): array 
    {
        $data = $this->haveIssetReceiveData(['user_id'=>0,'user_info'=>[],'type'=>' ','card_id'=>0,'card_info'=>[],'money'=>0,'update_ip'=>' ','app_id'=>0]);
        $validate = validate($this->withdrawValidate);
        if(!$validate->check($data)){ return verify_err(null, $validate->getError()); }
        if(!$validate->scene('check_card_info')->check($data['card_info'])){ return verify_err(null, $validate->getError()); }
        if(!$validate->scene('check_user_info')->check($data['user_info'])){ return verify_err(null, $validate->getError()); }

        return $this->stepRun($data, 'applyDrawwith', 'applyDrawwith', $this->withdrawValidate, $this->withdrawLogic);
    }*/

    /*我的 - 申请提现列表（分页）*/
   /* public function withdrawList($data): array 
    {
        //  $data = init_array($data,['user_id'=>0,'status'=>'','page'=>1,'listRows'=>15, 'time'=>'']);
        // if (empty($data)) {
        //     return null_data($data,"参数不能为空！");
        // }
        // $validateInitData = ['status' => true,'action'=>'withdrawList'];
        // ValidateWithdraw::checkValidate($data, ['user_id', 'status','page','listRows','time'], true, $validateInitData);
        //  return (new WithdrawLogic())->withdrawList($data);

         $data = $this->haveIssetReceiveData(['user_id'=>0,'status'=>'','page'=>1,'listRows'=>15, 'time'=>''], ['']);
        return $this->stepRun($data, 'withdrawList', 'withdrawList', $this->withdrawValidate, $this->withdrawLogic);
    }*/

    /*管理员 - 获取提现列表*/
    public function adminWithdrawList($data): array 
    {
         $data = init_array($data,['user_id'=>'','status'=>'','page'=>1,'listRows'=>15,'keywords'=>'']);
        if (empty($data)) {
            return null_data($data,"参数不能为空！");
        }
        $validateInitData = ['status' => true,'action'=>'adminWithdrawList'];
        ValidateWithdraw::checkValidate($data, ['user_id', 'status','page','listRows','keywords'], true, $validateInitData);
         return (new WithdrawLogic())->withdrawList($data);
    }

    /*管理员 - 审核提现*/
    public function auditWithdraw($data): array 
    {
        $token = (new Token())->hGetAll($data['token']);
        if($token['res']['status'] != SUCCESS_STATUS){
            return $token;
        }
        $data['update_ip'] = Request::getClientIp();
        $data['review_id'] = $token['res']['id'];
        $data['review_info'] = $token['res'];
        $data = init_array($data,['id'=>0, 'status'=>0, 'review_id'=>0, 'review_info'=>[], 'update_ip'=>' ']);
        if (empty($data)) {
            return null_data($data,"参数不能为空！");
        }
        $validateInitData = ['status' => true,'name'=>true ,'action'=>'auditWithdraw'];
        ValidateWithdraw::checkValidate($data, ['id', 'status','review_id','review_info','update_ip'], true, $validateInitData);
         return (new WithdrawLogic())->auditWithdraw($data);
    }

    /*管理员 - 审核转账*/
    public function auditTransfer($data): array 
    {
        $token = (new Token())->hGetAll($data['token']);
        if($token['res']['status'] != SUCCESS_STATUS){
            return $token;
        }
        $data['transfer_id'] = $token['res']['id'];
        $data['transfer_info'] = $token['res'];
        $data['update_ip'] = Request::getClientIp();
        $data = init_array($data,['id'=>0, 'status'=>0, 'transfer_id'=>0, 'transfer_info'=>[], 'update_ip'=>' ', 'app_id'=>0]);
        if (empty($data)) {
            return null_data($data,"参数不能为空！");
        }
        $validateInitData = ['status' => true,'action'=>'auditTransfer'];
        ValidateWithdraw::checkValidate($data, ['id', 'status','transfer_id','update_ip'], true, $validateInitData);
         return (new WithdrawLogic())->auditTransfer($data);
    }

}